package com.sutuijingling.utils;

import com.google.gson.o;
import com.sutuijingling.bean.d;
import com.sutuijingling.result.c;
import java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.a.e;

public abstract class f {
    public static final f a = new f() {
        public /* synthetic */ Object a(HttpResponse httpResponse) throws c {
            return d(httpResponse);
        }

        public Boolean d(HttpResponse httpResponse) throws c {
            int statusCode = httpResponse.getStatusLine().getStatusCode();
            switch (statusCode) {
                case HttpStatus.SC_OK /*200*/:
                    f.b(httpResponse);
                    return Boolean.TRUE;
                default:
                    throw new c(statusCode, f.c(httpResponse));
            }
        }
    };
    public static f b = new f() {
        public /* synthetic */ Object a(HttpResponse httpResponse) throws c {
            return d(httpResponse);
        }

        public String d(HttpResponse httpResponse) throws c {
            super.a(httpResponse);
            return f.c(httpResponse);
        }
    };
    public static f c = new f() {
        public /* synthetic */ Object a(HttpResponse httpResponse) throws c {
            return d(httpResponse);
        }

        public Long d(HttpResponse httpResponse) throws c {
            super.a(httpResponse);
            return Long.valueOf(f.c(httpResponse));
        }
    };
    public static f d = new f() {
        public /* synthetic */ Object a(HttpResponse httpResponse) throws c {
            return d(httpResponse);
        }

        public Integer d(HttpResponse httpResponse) throws c {
            super.a(httpResponse);
            return Integer.valueOf(f.c(httpResponse));
        }
    };
    public static f e = new f() {
        public /* synthetic */ Object a(HttpResponse httpResponse) throws c {
            return d(httpResponse);
        }

        public Boolean d(HttpResponse httpResponse) throws c {
            super.a(httpResponse);
            return Boolean.valueOf(f.c(httpResponse));
        }
    };
    public static f f = new f() {
        public /* synthetic */ Object a(HttpResponse httpResponse) throws c {
            return d(httpResponse);
        }

        public Boolean d(HttpResponse httpResponse) throws c {
            super.a(httpResponse);
            return Boolean.valueOf(new o().a(f.c(httpResponse)).k().b("isOk").f());
        }
    };
    public static f g = new f() {
        public /* synthetic */ Object a(HttpResponse httpResponse) throws c {
            return d(httpResponse);
        }

        public d d(HttpResponse httpResponse) throws c {
            super.a(httpResponse);
            return (d) new com.google.gson.f().a((String) b.a(httpResponse), d.class);
        }
    };

    public static final void b(HttpResponse httpResponse) {
        if (httpResponse != null && httpResponse.getEntity() != null) {
            try {
                HttpEntity entity = httpResponse.getEntity();
                if (entity != null) {
                    entity.consumeContent();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static final String c(HttpResponse httpResponse) {
        if (httpResponse == null) {
            return e.a;
        }
        HttpEntity entity = httpResponse.getEntity();
        if (entity == null) {
            return e.a;
        }
        try {
            String a = e.a(entity);
            System.out.println(" back res :" + a);
            return a;
        } catch (IOException e) {
            System.err.println(e.getMessage());
            return e.a;
        }
    }

    public Object a(HttpResponse httpResponse) throws c {
        int statusCode = httpResponse.getStatusLine().getStatusCode();
        switch (statusCode) {
            case HttpStatus.SC_OK /*200*/:
            case HttpStatus.SC_MOVED_PERMANENTLY /*301*/:
            case HttpStatus.SC_MOVED_TEMPORARILY /*302*/:
                return null;
            default:
                throw new c(statusCode, "Unknow Status Code");
        }
    }
}
